<?
  session_start();
  require_once("core.php");

  get_all_variables();
  $db = dbconnect();

   if (@$submitted==1) {
  /* User Input Analyse*/

/*  if (($nickname=='')||($password=='')){ header('Location: ../chat/msg.php?exitcode=2'); exit;} else

  if (strlen($nickname)<3){ header('Location: ../chat/msg.php?exitcode=3'); exit;} else

  if (strlen($password)<6){ header('Location: ../chat/msg.php?exitcode=5'); exit;}; */

  /* End of User Input Analyse */

  $username = addslashes($username);
  $password = addslashes($password);
  
  /* Database Check */
  $q = "
  SELECT *
  FROM `clients`
  WHERE (  login = '{$username}'  )  AND (  password = '{$password}'  )";
  $r = mysql_query($q, $db) or die(header('Location: /login.php'));

  $n = mysql_num_rows($r);
  $w = mysql_fetch_array($r);

  if ($n==0) { header('Location: /login.php'); exit;} else
  {
    $_SESSION['client'] = $w['id'];
    $_SESSION['nick'] = $w['title'];
	 header('Location: /dashboard.php'); exit;
  }

  /* End of Database Check */
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>openOli | Log in</title>
<link rel="icon" href="img/favicon.png" type="image/png" />
<link href="css/yahoo_reset.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/forms.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
        $(".pInfo").mouseover(function() { this.id="pInfoOn"})
        $(".pInfo").mouseout(function() { this.id=""})
        setInterval(function(){$("#timebox").load("time.php");}, 30000);
        })
</script>

<script type="text/javascript">
 function turnOnBg (elm) {
   elm.style.backgroundColor = "#FFFFFF";
 }

  function turnOffBg (elm) {
   elm.style.backgroundColor = "#FFFF99";
 }
</script>
</head>

<body>
  <!-- openOli::Contest | Turan Rustamli -->
  <div id="page">
  
    <div id="hdtext">
	   <div id="hdt_l">open source web based judge for holding olympiads in informatics</div>
	   <div id="hdt_r">English &nbsp; <img src="img/ico_mail.gif" alt="openOli" border="0"> &nbsp; <img src="img/ico_home.gif" alt="openOli" border="0"></div>
	</div>
    
	<div id="header">
	   <div id="logo"><a href="#"><img src="img/logo.jpg" alt="openOli" border="0"></a></div> 	    
	   <div id="topmenu">
            <a class="foxbtn" href="products.php"><span>Help</span></a>
	   </div> 	    
	   <div id="toolbox">		  
		  <div id="timebox">
	          <? include('time.php'); ?>
		  </div>
		</div> 	    
	</div>
	
	<div id="content">
	   <table width="100%" border="0" cellspacing="2">
		<tr>
			<td>
               <p class="p_section">Log in</p>
	           <p class="p_text">You need an account to log in. If you are not registered, please follow this <a href="register.php" title="Registration">link</a>.</p>
			   <form action="login.php" method="post">
			     <label for="username" class="hm_smallfont">Username: </label><input name="username" type="text" id="username" class="hm_input" onfocus="turnOnBg(this)" onblur="turnOffBg(this)" /><br />

			     <label for="password" class="hm_smallfont">Password: </label><input name="password" type="password" id="password" class="hm_input" onfocus="turnOnBg(this)" onblur="turnOffBg(this)" /><br /><br />

                 <input type="submit" value="Login" style="font-size: 22px; margin-left: 103px;" />
		         <input type="hidden" value="1" name="submitted" id="submitted" />
               </form>
               <br /><br />
 	           <p class="p_text">Forgot your password? <a href="password.php" title="Reset Password">Click here</a> to reset it.</p>
			
			</td>
			<td id="sidebar" height="520">
			   <p class="p_title">Information</p>
			   <p class="p_text"><b>Welcome!</b> Lorem ipsum has debet copiosae definitionem ei, nec ei sumo magna expetendis, sed eu summo sententiae consectetuer.</p>
			   <img src="img/logos.jgg" />
		    </td>
		</tr>
       </table>
	</div>	
	
	<div id="bottom"><span id="b_left">&copy; Turan Rustamli - You may use openOli under the terms of the MIT License.</div></div>	
	<br />
  </div>
</body>
</html>
